package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by windo on 16/7/12.
 */
public class PostMyAnswerTask extends CouponHttpBaseTask {

    private String wentiId;
    private String myAnswer;
    private int myscore;

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("questionId", wentiId);
            jsonObject.put("userAnswer", myAnswer);
            jsonObject.put("rewardCount", myscore);
            request.setApiNo(ApiNo.POSTMYANSWER);
            request.setData(jsonObject.toString());
            addRequest(request);
        }
    }

    public PostMyAnswerTask(String questionId, String answer, int score) {
        super();
        wentiId = questionId;
        myAnswer = answer;
        myscore = score;
    }
}
